package app.android.com.wuandroidapp.test.model.repository;

import android.content.Context;
import android.util.Log;

import app.android.com.wuandroidapp.test.model.db.entities.minimalist.Data;
import app.android.com.wuandroidapp.test.model.db.entities.minimalist.HelpPromodtionDetail;
import app.android.com.wuandroidapp.test.model.http.HttpService;
import app.android.com.wuandroidapp.test.model.http.OKCallBack;
import rx.Observable;
import rx.Subscriber;

/**
 * Created by admin on 2017/4/22.
 */

public class PromodtionRepository {

    public static Observable<HelpPromodtionDetail> getTest(Context context) {

        Observable<HelpPromodtionDetail> observableForGetWeatherFromDB = Observable.create(new Observable.OnSubscribe<HelpPromodtionDetail>() {
            @Override
            public void call(Subscriber<? super HelpPromodtionDetail> subscriber) {
                HttpService.getStpromotion(new OKCallBack() {
                    @Override
                    public void onSuccess(Data response) {
                        HelpPromodtionDetail re = (HelpPromodtionDetail) response.data;
                        subscriber.onNext(re);
                        subscriber.onCompleted();

                    }

                    @Override
                    public void onError(String message) {
                        Log.e("Http",message);
                    }
                });


            }

        });


        return observableForGetWeatherFromDB;
    }
}
